home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 151-175 / scopedisk168 / asmmacros / am_02 / coremacros.i < prev    next >
Text File  |  1995-03-19  |  4KB  |  153 lines

  1.      NOLIST
  2. DefineSections MACRO            ; 25 Dec 88
  3. *-------------------------------;    Start of DefineSections macro.
  4.                NOLIST
  5.                IFEQ NARG-1
  6.                LIST
  7.                IDNT "\1"
  8.                NOLIST
  9.                ENDC
  10.                IFND ReEntrant
  11. ReEntrant      SET 0
  12. CurrentLibID   SET 0
  13.                ENDC
  14.                IFND CAPE
  15.                LIST
  16. MetacomcoFix:  SECTION   "",CODE             ; This un-named code section
  17.                JMP CodeStart                 ;  is needed to fix a bug in
  18.                                              ;  the MetaComCo assembler.
  19.                NOLIST
  20.                ENDC
  21.                LIST
  22. DefDSPointer   SET 0
  23.                SECTION   CodeSection,CODE    ; Relocatable code section
  24. CodeStart:
  25.                SECTION   DataSection,DATA    ; Initialized data section
  26. DataStart:
  27.                SECTION   BSS_Section,BSS     ; Un-initialized data section
  28. BSS_Start:
  29.                SECTION   CodeSection,CODE    ; Relocatable code section
  30. *-------------------------------;    End of DefineSections macro.
  31.                ENDM
  32. CallLib   MACRO          ; 9 Feb 89
  33.      NOLIST
  34.      IFND _LVO\1.Ref
  35. _LVO\1.Ref SET 1
  36.      LIST
  37.         XREF _LVO\1
  38.      NOLIST
  39.      ENDC
  40.      IFEQ ReEntrant-1
  41.      LIST
  42.         MOVE.L \2.library.ptr(A5),A6
  43.      NOLIST
  44.      ENDC
  45.      IFNE ReEntrant-1
  46.      LIST
  47.         MOVE.L \2.library.ptr,A6
  48.      NOLIST
  49.      ENDC
  50.      LIST
  51.         JSR _LVO\1(A6)
  52.      ENDM
  53.  
  54. OpenLib   MACRO                ; 25 Dec 88
  55. *------------------------------; Start of OpenLib macro.
  56.      NOLIST
  57.                                ; Define _AbsExecBase and _LVOOpenLibrary if
  58.      IFND _AbsExecBase         ;  they have not yet been defined.
  59.      LIST
  60.      XREF _AbsExecBase
  61.      NOLIST
  62.      ENDC
  63.      IFND _LVOOpenLibrary
  64.      LIST
  65.      XREF _LVOOpenLibrary
  66.      NOLIST
  67.      ENDC
  68.      LIST
  69.      MOVE.L _AbsExecBase,A6    ; Do set-up for _LVOOpenLibrary.
  70.      CLR.L D0
  71.      MOVE.L #\1.str,A1
  72.      SECTION DataSection,DATA  ; This is the <libname> ASCII string.
  73. \1.str:
  74.      DC.B '\1',0
  75.      CNOP 0,2
  76.      SECTION CodeSection,CODE
  77.      JSR _LVOOpenLibrary(A6)   ; Call OpenLibrary to open <libname>.
  78.      NOLIST
  79.      IFEQ ReEntrant-1
  80.      LIST
  81.      DefDS \1.ptr,1
  82.      MOVE.L D0,\1.ptr(A5)
  83.      NOLIST
  84.      ENDC
  85.      IFNE ReEntrant-1
  86.      LIST
  87.      MOVE.L D0,\1.ptr
  88.      DS_BSS \1.ptr,1,.L
  89.      NOLIST
  90.      ENDC
  91.      LIST
  92.      TST.L D0                  ; Make the zero flag indicate failure.
  93. *------------------------------; End of OpenLib macro.
  94.      ENDM
  95.  
  96. CloseLib       MACRO           ; 13 Sept 88
  97. *------------------------------; Start of CloseLib macro.
  98.                                ; Put the library pointer in A1.
  99.      NOLIST
  100.      IFEQ ReEntrant-1
  101.      LIST
  102.      MOVE.L \1.ptr(A5),A1
  103.      NOLIST
  104.      ENDC
  105.      IFNE ReEntrant-1
  106.      LIST
  107.      MOVE.L \1.ptr,A1
  108.      NOLIST
  109.      ENDC
  110.      LIST
  111.      CallLib CloseLibrary,exec ; Call CloseLibrary.
  112. *------------------------------; End of CloseLib macro.
  113.      ENDM
  114.  
  115. DefDS          MACRO     ; 26 Dec 88
  116.                NOLIST
  117.                IFND \1
  118. \1             EQU DefDSPointer
  119. DefDSPointer   SET DefDSPointer+(4*\2)
  120.                ENDC
  121.                LIST
  122.                ENDM
  123.  
  124. DS_BSS    MACRO          ; 13 Sept 88
  125.           NOLIST
  126.           IFND \1
  127.           SECTION BSS_Section,BSS
  128.           IFC "\3",".W"
  129.           CNOP 0,2
  130.           ENDC
  131.           IFC "\3",".L"
  132.           CNOP 0,4
  133.           ENDC
  134. \1:
  135.           DS\3 \2
  136.           SECTION CodeSection,CODE
  137.           ENDC
  138.           LIST
  139.           ENDM
  140.  
  141. OnReEntrant    MACRO     ; 13 Sept 88
  142.                NOLIST
  143. ReEntrant      SET 1
  144.                LIST
  145.                ENDM
  146.  
  147. OffReEntrant   MACRO     ; 13 Sept 88
  148.                NOLIST
  149. ReEntrant      SET 0
  150.                LIST
  151.                ENDM
  152.      LIST
  153.